package com.zc.app.sys.service;

import com.github.pagehelper.PageHelper;
import com.zc.app.sys.dao.mapper.SystemRolePeerMapper;
import com.zc.app.sys.dao.peer.SystemRolePeer;
import com.zc.framework.common.bean.MyPageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zc on 2016/11/23.
 */
@Service
public class SystemRoleService {
    @Autowired
    private SystemRolePeerMapper systemRolePeerMapper;


    public int createRole(SystemRolePeer systemRolePeer) {
        return systemRolePeerMapper.insert(systemRolePeer);
    }

    public MyPageInfo<SystemRolePeer> queryPageRoles(SystemRolePeer systemRolePeer, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new MyPageInfo<SystemRolePeer>(systemRolePeerMapper.queryRoles(systemRolePeer));
    }

    public List<SystemRolePeer> queryRoles() {
        return systemRolePeerMapper.queryRoles(new SystemRolePeer());
    }


    public SystemRolePeer queyRoleById(Integer roleId){
        return systemRolePeerMapper.selectByPrimaryKey(roleId);
    }

    public Integer updateRole(SystemRolePeer rolePeer){
        return systemRolePeerMapper.updateByPrimaryKey(rolePeer);
    }

}
